package com.frikinet.tools.gui;

import java.awt.Component;
import java.io.File;

import javax.swing.JOptionPane;

import com.frikinet.tools.i18n.FI18N;

public class FOptionPane extends JOptionPane
{
	private static final long serialVersionUID = 1L;

	public static boolean showConfirmDialog(Component parentComponent, FI18N i18n, String group)
	{
		int answer = showConfirmDialog(parentComponent, i18n.translate(String.format("%s.text", group)), i18n.translate(String.format("%s.title", group), ""), YES_NO_OPTION);
		return answer == YES_OPTION;
	}
	
	public static boolean showConfirmDialog(Component parentComponent, FI18N i18n, String group, Object... params)
	{
		int answer = showConfirmDialog(parentComponent, i18n.translate(String.format("%s.text", group), params), i18n.translate(String.format("%s.title", group), ""), YES_NO_OPTION);
		return answer == YES_OPTION;
	}
	
	public static boolean showConfirmOverwrite(Component parentComponent, FI18N i18n, String group, File file)
	{
		if(!file.exists())
			return true;
		
		return showConfirmDialog(parentComponent, i18n, group, file.getName());
	}
}
